package com.yc.springmvc.controller;

import java.util.List;	
import java.util.Map;

import javax.servlet.http.HttpSession;


import com.yc.springmvc.biz.IUserInfoBiz;
import com.yc.springmvc.core.annotation.Autowired;
import com.yc.springmvc.core.annotation.Controller;
import com.yc.springmvc.core.annotation.RequestMapping;
import com.yc.springmvc.core.annotation.RequestParam;
import com.yc.springmvc.core.annotation.ResponseBody;
import com.yc.springmvc.entity.UserInfo;

@Controller
@RequestMapping("/user")
public class UserInfoController {
	@Autowired
	private IUserInfoBiz userInfoBiz;
	
	@RequestMapping("/finds")
	@ResponseBody  // 以json格式返回数据
	public List<UserInfo> finds(){
		return userInfoBiz.finds();
	}
	
	@RequestMapping("/add")
	@ResponseBody  // 以json格式返回数据
	public UserInfo add(UserInfo uf){
		System.out.println(uf);
		return uf;
	}
	
	@RequestMapping("/reg")
	@ResponseBody  // 以json格式返回数据
	public Map<String, Object> reg(Map<String, Object> map, HttpSession session){
		System.out.println(map);
		session.setAttribute("map", map);
		return map;
	}
	
	@RequestMapping("/find")
	public String find(@RequestParam("tid") String sid, UserInfo uf, String company) {
		System.out.println(sid);
		System.out.println(uf);
		System.out.println(company);
		return "redirect: ../success.html";
		
	}
}
